yjx.controller('cRelationshipController',['$rootScope','$scope','$stateParams','$fetch','modalService','ipCookie','$timeout',function ($rootScope,$scope,$stateParams,$fetch,modalService,ipCookie,$timeout) {
    $scope.customerId = $stateParams.customerId;
    $scope.customerName = $stateParams.customerName;
    $rootScope.tabCtrlName = $rootScope.tabCtrlNameArr[3];
    /*获取该客户的关系列表*/
    function getRelationList(){
        $fetch.fetch(
            '/customer/relation/tree',
            {
                params:{
                    userId:$rootScope.userId,
                    customerId:$scope.customerId,
                },
                type:'POST'
            }
        ).then(function(data){
                $timeout(function(){
                    if(data && data.relationTree){
                        $scope.relationList = data.relationTree
                    }else{
                        $scope.relationList = [];
                    }
                })
            })
    }
    if($scope.customerId) {
        getRelationList();
    }
    /**/


    /*预约客户*/
    var reservationMsg = "该用户已预约成功！<br>您将在待办事项中收到提醒！"
    $scope.reservation = function (id) {
        /*调接口*/
        $fetch.fetch(
            '/customer/bespeak',
            {
                params:{
                    userId:$rootScope.userId,
                    customerIds:id,
                    type:1
                },
                cache:false
            }
        ).then(function(data){
                modalService.mainMsgInfo("待办事项中将出现这些提醒",'','预约成功')
            }).catch(function(e){
                modalService.mainMsgError(e.msg);
            })
    }
}])